<?php 
	require_once './utils/DBUtil.php';
	$mid = $_GET['musicId'];
?>
<html>
<head>
<title>Details Page</title>
  <link href="./css/header.css" rel="stylesheet">
  <link href="./css/details.css" rel="stylesheet">
</head>
<body>
<div id="nav">
	<a href="./design.php">Database Design and Implementation</a>
	<a href="./index.php">Search</a>
</div>
<div class="detail">
	<?php 
		$sql = "select * from singer s,musics m ,genres g, musics_genre mg where s.id = m.singer and m.id = mg.musics_id and g.id = mg.genres_id and m.id = ".$mid;
		#echo $sql;
		$con = getConn();
		$con->exec("set names utf8"); 
		$result = $con->query($sql);
		
		foreach($result as $re){
			$singerid = $re[0];
		?>
		<div class="detailstitle">
			<h1><?php echo $re[5]?></h1>
			<div class="year">year : <?php echo $re[6]?></div>
			<div class="singer">singer : <?php echo $re[1]." ".$re[2]?></div>
			<div class="genre">genre : <?php echo $re[9]?></div>
			<div class="photo">
				<img src="<?php echo $re[3]?>">
			</div>
		</div>
		<div class="rec">
			<h2>Recommended Musics</h2>
			<?php 
			$sql = "select * from musics where id!=".$re[4]." and singer = ".$singerid;
			#echo $sql;
				$recs = $con->query($sql);
				foreach($recs as $rec){
					?>
					<div class="item">
						<a href="details.php?musicId=<?php echo $rec[0]?>"><?php echo $rec[1] ?></a>
					</div>
					<?php 
				}
			?>
		</div>
		<?php 
		}
	?>
</div>
</body>
</html>